package com.file.exercise;

import java.io.File;
import java.util.HashMap;

/**
 * @author げっしょく
 * @date 2021/7/31
 */
public class Test7 {
    public static void main(String[] args) {
        File file = new File("Day12");
        HashMap<String , Integer> hm = new HashMap<>();
        count(file , hm);
        System.out.println(hm);

    }
    public static void count(File dir , HashMap<String , Integer> hm){
        File[] files = dir.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isFile()) {
                    String name = file.getName();
                    String[] split = name.split("\\.");
                    if (hm.containsKey(split[1])){
                        Integer integer = hm.get(split[1]);
                        integer++;
                        hm.put(split[1] , integer);
                    }else {
                        hm.put(split[1] , 1);
                    }
                }else{
                    count(file , hm);
                }
            }
        }
    }
}
